package com.situ.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.situ.domain.dto.OrderReportDTO;
import com.situ.domain.entity.TOrderItem;
import com.situ.domain.entity.TOrderItemExample;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface TOrderItemMapper extends BaseMapper<TOrderItem> {
    long countByExample(TOrderItemExample example);

    int deleteByExample(TOrderItemExample example);

    int deleteByPrimaryKey(Integer id);

    int insert(TOrderItem record);

    int insertSelective(TOrderItem record);

    List<TOrderItem> selectByExample(TOrderItemExample example);

    TOrderItem selectByPrimaryKey(Integer id);

    int updateByExampleSelective(@Param("record") TOrderItem record, @Param("example") TOrderItemExample example);

    int updateByExample(@Param("record") TOrderItem record, @Param("example") TOrderItemExample example);

    int updateByPrimaryKeySelective(TOrderItem record);

    int updateByPrimaryKey(TOrderItem record);

    /**
     * 查询订单统计信息
     * @return
     */
    @Select("select pid,title,sum(num) as totalNum from t_order_item group by pid,title")
    List<OrderReportDTO> getOrderReport();

    /**
     * 获取营热门商品信息
     * @return
     */
    List<OrderReportDTO> getBusinessOrderReport();

    @Select("select count(num) from t_order_item")
    Long getTotalnums();
}